// start layer
var g_startLayer;
var StartLayer = cc.Layer.extend({
    ///////////// constructor ///////////////////
    ctor:function () {
        // super init first
        this._super();
        g_startLayer = this;
        // add canvas
        this.addCanvas();
        // add menu
        this.AddMenu();
    },
    addCanvas : function(){
        var filename = StartResource("sCanvas.jpg");
        var background = new cc.Sprite(filename);
        background.setPosition( cc.p(cc.winSize.width/2,cc.winSize.height/2) );
        this.addChild(background);
    },
    AddMenu : function(){
        var filename0 = StartResource("sPlay0.png"),filename1 = StartResource("sPlay1.png");
        var begin = new cc.MenuItemImage(filename0,filename1,this.onPlaying , this);
        begin.setPosition( cc.p(cc.winSize.width*0.5+20,160) );
        var menu = cc.Menu.create( begin );
        menu.setPosition(cc.p(0,0));
        this.addChild( menu );
    },
    onPlaying : function(sender){
        cc.audioEngine.stopMusic(true);
        cc.textureCache.removeAllTextures();
        cc.spriteFrameCache.removeSpriteFrames();
        Loading.preload(g_mainRes, function () {
            cc.director.runScene( new MainScene() );
        }, this);
    }
});
